/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gov.mtc.dgac.licencias.bean;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author elvis
 */
@Entity
@Table(name = "AUDITOR")
@NamedQueries({@NamedQuery(name = "AuditorTO.findByCodAuditor", query = "SELECT a FROM AuditorTO a WHERE a.codAuditor = :codAuditor"), @NamedQuery(name = "AuditorTO.findByApePaterno", query = "SELECT a FROM AuditorTO a WHERE a.apePaterno = :apePaterno"), @NamedQuery(name = "AuditorTO.findByApeMaterno", query = "SELECT a FROM AuditorTO a WHERE a.apeMaterno = :apeMaterno"), @NamedQuery(name = "AuditorTO.findByNombres", query = "SELECT a FROM AuditorTO a WHERE a.nombres = :nombres")})
public class AuditorTO implements Serializable {
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = "SEQAUDITOR")
    @SequenceGenerator(name="SEQAUDITOR", sequenceName="SEQ_AUDITOR",allocationSize=1)
    @Column(name = "COD_AUDITOR", nullable = false)
    private Long codAuditor;
    @Column(name = "APE_PATERNO", nullable = false)
    private String apePaterno;
    @Column(name = "APE_MATERNO", nullable = false)
    private String apeMaterno;
    @Column(name = "NOMBRES", nullable = false)
    private String nombres;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codAuditor")
    private Collection<AuditorTipoauditTO> auditorTipoauditTOCollection;

    public AuditorTO() {
    }

    public AuditorTO(Long codAuditor) {
        this.codAuditor = codAuditor;
    }

    public AuditorTO(Long codAuditor, String apePaterno, String apeMaterno, String nombres) {
        this.codAuditor = codAuditor;
        this.apePaterno = apePaterno;
        this.apeMaterno = apeMaterno;
        this.nombres = nombres;
    }

    public Long getCodAuditor() {
        return codAuditor;
    }

    public void setCodAuditor(Long codAuditor) {
        this.codAuditor = codAuditor;
    }

    public String getApePaterno() {
        return apePaterno;
    }

    public void setApePaterno(String apePaterno) {
        this.apePaterno = apePaterno;
    }

    public String getApeMaterno() {
        return apeMaterno;
    }

    public void setApeMaterno(String apeMaterno) {
        this.apeMaterno = apeMaterno;
    }

    public String getNombres() {
        return nombres;
    }

    public void setNombres(String nombres) {
        this.nombres = nombres;
    }

    public Collection<AuditorTipoauditTO> getAuditorTipoauditTOCollection() {
        return auditorTipoauditTOCollection;
    }

    public void setAuditorTipoauditTOCollection(Collection<AuditorTipoauditTO> auditorTipoauditTOCollection) {
        this.auditorTipoauditTOCollection = auditorTipoauditTOCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codAuditor != null ? codAuditor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AuditorTO)) {
            return false;
        }
        AuditorTO other = (AuditorTO) object;
        if ((this.codAuditor == null && other.codAuditor != null) || (this.codAuditor != null && !this.codAuditor.equals(other.codAuditor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "licencias_dto.p2.AuditorTO[codAuditor=" + codAuditor + "]";
    }

    public String getNombreCompleto(){
        return this.nombres + " "  + this.apePaterno;
    }
}
